import sys
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLineEdit, QCompleter

class MainWindow(QWidget):
    def __init__(self):
        super().__init__()

        # 创建一个QLineEdit作为搜索框
        self.search_box = QLineEdit(self)
        self.search_box.setPlaceholderText("请输入搜索内容...")

        # 创建一个QCompleter，用于提供自动完成提示
        self.completer = QCompleter(["苹果", "橘子", "香蕉", "梨", "葡萄"])
        self.search_box.setCompleter(self.completer)

        # 设置布局
        layout = QVBoxLayout()
        layout.addWidget(self.search_box)
        self.setLayout(layout)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())
